//路由守卫
import router from '@/router'
import login from '@/api/login'


router.beforeEach(async (to, from, next) => {
    if(to.path == "/login") {
        next()
    }else{
        let token = localStorage.getItem('jinfeng-mms-token')
        if(token == null || token == "") {
            next('/login')
        }else{
            try{
                let p = await login.getuserIn(token)
                if(p.data.flag){
                    next()
                }else{
                    next('/login')
                }
            }catch(err){console.log(err);}
        }
    }
})